# Copyright(c) 2008 Tri Tech Information Systems Inc. 
# Distributed under the Boost Software License, Version 1.0.
#     (See accompanying file ../../LICENSE_1_0.txt or copy at
#           http://www.boost.org/LICENSE_1_0.txt)
#

def recurse():
    """
    >>> from interface import *

    Since we are heading in/out of C++, we cannot assume
    we'll be able to do the whole regular recursion limit
    especially since boost.python tends to introduce a lot of
    functions.
    >>> import sys
    >>> sys.setrecursionlimit(100)

    This test will recurse in and out of c++
    to produce a maximum recursion limit error

    >>> def what():
    ...     callme(what)

    The moment of truth
    >>> what()
    Traceback (most recent call last):
        ...
    RuntimeError: maximum recursion depth exceeded...
    """

def my_error_test():
    """
    >>> from interface import *

    Try out an exception class

    >>> throw_fit()
    Traceback (most recent call last):
        ...
    my_error: fit

    >>> try:
    ...     throw_fit()
    ... except my_error:
    ...     print "YES!"
    ... else:
    ...     print "NO"
    YES!

    >>> from pyxx_helper import StdRuntimeError
    >>> try:
    ...     throw_fit()
    ... except StdRuntimeError:
    ...     print "YES!"
    ... else:
    ...     print "NO"
    YES!

    >>> raise my_error("from python")
    Traceback (most recent call last):
        ...
    my_error: from python

    >>> catcher(throw_fit)
    True

    >>> def bland():
    ...     pass
    >>> catcher(bland)
    False


    >>> def stupid():
    ...     raise Exception("I am broken")
    >>> catcher(stupid)
    Traceback (most recent call last):
        ...
    Exception: I am broken

    """

if __name__ == '__main__':
    import doctest
    import sys
    sys.exit(doctest.testmod(optionflags = doctest.ELLIPSIS)[0])


